Skip Navigation
Updated
May 30, 2024

WPML lets you redirect visitors to their preferred language, offering their native content as default.

To enable browser language redirect, go to WPMLLanguages page, and find the Browser language redirect.

Browser language redirect

The default is to not redirect visitors. If you choose to redirect visitors, you can have two options:

  • Only redirect visitors if translations exist
  • Always redirect visitors. If you choose to always redirect, visitors will go to translated content when it exists or to the homepage in the default language if there is no matching translation.

Looking to redirect visitors based on IP instead of browser language?

While WPML doesn’t currently have a native feature for this, there are some great WPML-compatible geotargeting plugins that can help you achieve this on your multilingual site.

Potential Interaction with Google Indexing

As of 2015, Google follows all redirects, including those implemented in Javascript. This may cause Google to think that your content permanently redirects to content in other language. Read more about how browser language redirect affects Google Indexing.

No Redirection When Refreshing the Browser

WPML will do this language redirect only once and then not redirect anymore. We do this to allow visitors to still switch languages. If we always push back to the browser’s language, visitors will not be able to manually switch languages after WPML redirects them to the language set by their browser.

This single-time redirect operation resets every 24 hours (which you can change too).

How Browser Language Redirection Works

WPML uses Javascript code for the browser language redirect. This way, the redirection is fastest, as it happens in the visitor’s browser. It’s also resilient to caching plugins.

However, the language redirect mechanism may fail if your site is running other plugins that also redirect based on Javascript. Some maintenance plugins may do that.

Effects on the Page Loading Time

To detect the preferred language, the redirect feature needs the browser to fully load the site. Then, it reloads the page with the language matching the browser.

This happens only the first time a user visits the site but does make the page load longer than usual as it loads twice.

But my browser and my site are both in English, why does it affect it?

Even if your browser and website are both set to English, the reloading can still happen if you have enabled the automatic redirect.

Some examples when this might happen:

  • Browser language is set to a dialect of English, such as en-us
  • Browser is loading the site for the first time
  • Browser has no language cookies set
  • You are using the Firefox browser

Effects on Site Speed Testing Tools

Automatic redirection based on browser language might impact the results provided by tools that measure site speed (e.g. GTmetrix). This happens because such services might not have any language set.

Tip: Always Include a Language Switcher on the Page

The browser language detection is intended to send visitors to the content which will match their language preference, on the first visit. You should always allow visitors to choose their preferred language using a language switcher. If you rely exclusively on the automatic language redirection, some visitors will receive content in languages that they cannot understand and will not be able to switch to their preferred language.

Debugging Browser Language Redirection

If you’ve enabled browser language redirection and it isn’t working when you test it, check the following:

  • Is your browser’s language set? Check it in your browser’s language settings.
  • Are you using a new session? Remember that WPML will only redirect once. You need to clear all cookies or start an incognito browser (which always has a fresh history). This starts a clean session and simulates a new visitor.
  • Are there any Javascript errors on the page? You can view Javascript errors using ToolsJavascript Console in Chrome and Firefox.
  • Are you using any other plugins that might be redirecting visitors too? Review your active plugins and see which ones might be involved.
  • Is the language you expect to be redirected to hidden? Make sure you enable Display hidden languages from your user profile.